<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增直播间信息')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-room-add">
            <input type="hidden" name="coverImg">
            <input type="hidden" name="shareImg">
            <input type="hidden" name="feedsImg">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">直播间名字：</label>
                <div class="col-sm-8">
                    <input name="name" class="form-control" type="text" required>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 最短3个汉字，最长17个汉字，1个汉字相当于2个字符</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">背景图：</label>
                <div class="col-sm-8">
                    <input id="coverImg" name="file" type="file">
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 尺寸1080x1920</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">直播计划开始时间：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" id="startTime" name="startTime" placeholder="yyyy-MM-dd HH:mm:ss" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">直播计划结束时间：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" id="endTime" name="endTime" placeholder="yyyy-MM-dd HH:mm:ss" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">主播昵称：</label>
                <div class="col-sm-8">
                    <input name="anchorName" class="form-control" type="text" required>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>最短2个汉字，最长15个汉字，1个汉字相当于2个字符</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">主播微信号：</label>
                <div class="col-sm-8">
                    <input name="anchorWechat" class="form-control" type="text" required>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>如果未实名认证，需要先前往“小程序直播”小程序进行实名验证</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主播副号微信号：</label>
                <div class="col-sm-8">
                    <input name="subAnchorWechat" class="form-control" type="text">
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>如果未实名认证，需要先前往“小程序直播”小程序进行实名验证</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">创建者微信号：</label>
                <div class="col-sm-8">
                    <input name="createrWechat" class="form-control" type="text">
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>不传入则此直播间所有成员可见。传入则此房间仅创建者、管理员、超管、直播间主播可见</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">分享图：</label>
                <div class="col-sm-8">
                    <input id="shareImg" name="file" type="file" >
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>1080x1920</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">购物直播频道封面图</label>
                <div class="col-sm-8">
                    <input id="feedsImg" name="file" type="file">
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>1080x1920</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否开启官方收录：</label>
                <div class="col-sm-8">
                    <select name="isFeedsPublic" class="form-control">
                        <option value="1" >开启</option>
                        <option value="0" selected>关闭</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否关闭点赞：</label>
                <div class="col-sm-8">
                    <select name="closeLike" class="form-control">
                        <option value="0" selected>开启</option>
                        <option value="1">关闭</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否关闭货架：</label>
                <div class="col-sm-8">
                    <select name="closeGoods" class="form-control">
                        <option value="0" selected>开启</option>
                        <option value="1">关闭</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否关闭评论：</label>
                <div class="col-sm-8">
                    <select name="closeComment" class="form-control">
                        <option value="0">开启</option>
                        <option value="1" selected>关闭</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否关闭回放：</label>
                <div class="col-sm-8">
                    <select name="closeReplay" class="form-control">
                        <option value="0" selected>开启</option>
                        <option value="1">关闭</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否关闭分享：</label>
                <div class="col-sm-8">
                    <select name="closeShare" class="form-control">
                        <option value="0" selected>开启</option>
                        <option value="1">关闭</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否关闭客服：</label>
                <div class="col-sm-8">
                    <select name="closeKf" class="form-control">
                        <option value="0">开启</option>
                        <option value="1" selected>关闭</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否推荐：</label>
                <div class="col-sm-8">
                    <select name="recommend" class="form-control">
                        <option value="0" selected>否</option>
                        <option value="1">是</option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否精选：</label>
                <div class="col-sm-8">
                    <select name="selected" class="form-control">
                        <option value="0" selected>否</option>
                        <option value="1">是</option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />

    <script th:inline="javascript">
        var prefix = ctx + "tea/room"
        $("#form-room-add").validate({
            focusCleanup: true
        });

        $("#startTime").datetimepicker({
            format: "yyyy-mm-dd hh:ii:ss",
            autoclose: true
        });

        $("#endTime").datetimepicker({
            format: "yyyy-mm-dd hh:ii:ss",
            autoclose: true
        });

        // 单图上传
        $("#coverImg").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true,
            showPreview: false,
            showRemove: false
        }).on('fileuploaded', function (event, data, previewId, index) {
            var rsp = data.response;
            log.info("return url：" + rsp.url)
            log.info("reutrn fileName：" + rsp.fileName)
            log.info("reutrn newFileName：" + rsp.newFileName)
            log.info("return originalFilename：" + rsp.originalFilename)
            $("input[name='coverImg']").val(rsp.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        // 单图上传
        $("#feedsImg").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true,
            showPreview: false,
            showRemove: false
        }).on('fileuploaded', function (event, data, previewId, index) {
            var rsp = data.response;
            log.info("return url：" + rsp.url)
            log.info("reutrn fileName：" + rsp.fileName)
            log.info("reutrn newFileName：" + rsp.newFileName)
            log.info("return originalFilename：" + rsp.originalFilename)
            $("input[name='feedsImg']").val(rsp.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })
        // 单图上传
        $("#shareImg").fileinput({
            uploadUrl: ctx + 'common/upload',
            maxFileCount: 1,
            autoReplace: true,
            showPreview: false,
            showRemove: false
        }).on('fileuploaded', function (event, data, previewId, index) {
            var rsp = data.response;
            log.info("return url：" + rsp.url)
            log.info("reutrn fileName：" + rsp.fileName)
            log.info("reutrn newFileName：" + rsp.newFileName)
            log.info("return originalFilename：" + rsp.originalFilename)
            $("input[name='shareImg']").val(rsp.url)
        }).on('fileremoved', function (event, id, index) {
            $("input[name='" + event.currentTarget.id + "']").val('')
        })

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-room-add').serialize());
            }
        }
    </script>
</body>
</html>